const connect=require("../app/databases")
class UserService{
    //传递一些参数
  async  create(ctx){
    // //讲解解析的json放在body里面
    //  console.log(ctx.request.body)
    const {name,password}=ctx.request.body
    //创建sql语句
    const statement= "insert into user (name,password) values (?,?)"
    //执行sql语句
      const result=await   connect.execute(statement,[name,password]);
       return   result;
    }
    //判断名字是否存在 
   async getName(name){
     const statment="select * from user where name=?"
     const result=await connect.execute(statment,[name])
  
     return result[0]
   }
}
// const userService=new UserService()

module.exports=new UserService()